<script>
//用户答题登陆页面，使用用户账号登陆，不需要密码

export default {
  name: "AccLogin",
  data() {
    return {
      userName: '',
    }
  },
  methods: {

    login() {
      const _this = this;
      const res = this.$http.get('accounts/acc_login?userName=' + this.userName).then(function (res) {
        if (res.data.success) {
          const account1 = res.data.data;
          //登陆成功
          sessionStorage.setItem("token", account1.token);
          sessionStorage.setItem("accountId", account1.id);
          sessionStorage.setItem("accAge", account1.age);
          sessionStorage.setItem("accRealName",account1.realName)
          // 跳转到后台主页面
          _this.$router.push({path: '/que_list'});
        } else {
          //登陆失败
          _this.$message.error(res.data.errMsg);
        }
      })

    },
    toggleFullScreen() {
      if (!document.fullscreenElement &&    // alternative standard method
          !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {  // current working methods
        if (document.documentElement.requestFullscreen) {
          document.documentElement.requestFullscreen();
        } else if (document.documentElement.msRequestFullscreen) {
          document.documentElement.msRequestFullscreen();
        } else if (document.documentElement.mozRequestFullScreen) {
          document.documentElement.mozRequestFullScreen();
        } else if (document.documentElement.webkitRequestFullscreen) {
          document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
        }
      } else {
        if (document.exitFullscreen) {
          document.exitFullscreen();
        } else if (document.msExitFullscreen) {
          document.msExitFullscreen();
        } else if (document.mozCancelFullScreen) {
          document.mozCancelFullScreen();
        } else if (document.webkitExitFullscreen) {
          document.webkitExitFullscreen();
        }
      }
    }
  }
}
</script>

<template>
  <div class="acc_login" ref="full_screen">
    <el-row class="div1">
      <el-input class="input1" v-model="userName" placeholder="请输入账号"></el-input>
      <el-button class="btn1" @click.prevent="login" type="primary">
        登&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;陆
      </el-button>
    </el-row>
  </div>
</template>

<style scoped>
.acc_login {
  width: 100%;
  height: 100%;
  background-image: url("@/assets/imgs/acc_login.jpg");
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.div1 {
  margin-top: 19%;
  width: 16%;
}

/deep/ .el-input__inner {
  background-color: #161541;
  border: 1px solid #4C9BD7;
  height: 45px;
  text-align: center;
  color: white;
  font-size: 28px;
}

/deep/ .btn1 {
  width: 100%;
  font-size: 25px;
  margin-top: 15px;
}
</style>